package org.neuedu.chapter04_0616;

public class ArrayDemo04 {
    public static void main(String[] args) {
        // 1.求和
        int[] arr = {1, 3, 5, 76, 8, 4, 3, 2, 5, 7};
        double sum = 0;
        for (int num : arr) {
            sum = sum + num;
        }
        // 2.求平均值
        System.out.println(sum/arr.length);
        // 3.求偶数和
        sum = 0;
        for (int num : arr) {
            if (num % 2 == 0) {
                sum = sum + num;
            }
        }
        System.out.println(sum);
        // 4.求最大值和它的下标
        int max = arr[0];
        int index = 0;
        int i = 0;
        for (int num : arr) {
            if (num > max) {
                max = num;
                i = index;
            }
            index++;
        }
        System.out.println(max+","+i);
    }
}
